<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" import="java.util.*"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ request.getContextPath() + "/";
//response.sendRedirect("common/login");
%>
<c:set var="path" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>FinanceOrgList</title>
			<script type="text/javascript" src="${path }/resource/js/jquery-1.8.3.min.js"></script>
			<script type="text/javascript" src="${path }/resource/js/mytools.js"></script>
			<script type="text/javascript" src="${path }/resource/layer/layer.js"></script>
			<script type="text/javascript" src="${path }/resource/layui/layui.js" ></script>
			<link rel="stylesheet" href="${path }/resource/layui/css/layui.css" />
	</head>
	<body >
<form class="layui-form layui-form-pane" id="searchFrom">
<div class="layui-form-item" >
    <div class="layui-inline">
     <label class="layui-form-label">机构名称:</label>
     <div class="layui-input-inline">
		<input type="text"  class="layui-input" autocomplete="off" name="orgName" />
	 </div>
  </div>	
    <div class="layui-inline">
     <label class="layui-form-label">机构类型:</label>
     <div class="layui-input-inline">
     <select lay-filter="orgType"  name="orgType" >
      <option value="">请选择</option>
	</select>
	 </div>
  </div>	
    <div class="layui-inline">
     <label class="layui-form-label">所属区域:</label>
     <div class="layui-input-inline">
     	<div class="layui-input-inline">
      		<select lay-filter="area" id="autoselect2" name="area" >
      			<option value="">请选择</option>
			</select>
	 	</div>
	 </div>
  </div>	
   <div class="layui-input-block">
     <input type="button" class="layui-btn layui-btn-small" onclick="mjs.search()" value='搜索'>
      <input type="reset" class="layui-btn layui-btn-primary layui-btn-small" value='重置'>	
    </div>
</div>
</form>
	<div id="tablediv">
	<table id="table1" class="layui-table">
	<thead id="thead">
		<tr>
		<th data-name = "orgName">机构名称</th>  
		<th data-name = "upDate" >成立日期</th>  
		<th data-name = "lawRepresent">法人代表</th>  
		<th data-name = "regAddr">地址</th>  
		<th data-name = "orgTel">联系电话</th>  
		<th data-name = "orgStatus" data-format="getStatus" >组织状态</th>  
		<th data-name = "id" data-format="operation">操作</th>  
		</tr>
	</thead>
	</table>
	</div>
	<br>
	<script>
	var $form; 
	var layer;
	var form;
	layui.use(['form', 'layedit', 'laydate'], function(){
		  form = layui.form();
		  layer = layui.layer;
		  layedit = layui.layedit;
		  laydate = layui.laydate;
		  $form = $('form');
		 //加载市级
		 loadArea();
		 loadorgType();
		 //监听提交
		});

    //加载机构类型
   function loadorgType() {
       var orgTypeHtml = '<option value="">请选择</option>';
       ///准备发射ajax请求得到数据
       var url = '${path}/common/Dictionary/showSelect';
       var data = {"dicType":"机构类型"};
       $.ajax({
	  		'type':'post',
	  		'url':url,
	  		'data':data,
	  		'dataType':'json',
	  		'success':function(data,status){
	  			for(var i=0;i<data.rows.length;i++){
	  				orgTypeHtml+="<option value='"+data.rows[i].dicValue+"' ";
	  				orgTypeHtml+="  >"+data.rows[i].dicValue+"</option>";
	  			}
	  			$form.find('select[name=orgType]').html(orgTypeHtml).parent().show();
	  	        form.render();
	  		}
	  	});
   }
	
     //加载市数据
    function loadArea() {
        var areaHtml = '<option value="">请选择</option>';
        ///准备发射ajax请求得到数据
        var url = '${path}/common/Dictionary/showSelect';
        var data = {"dicType":"所在区域"};
        $.ajax({
	  		'type':'post',
	  		'url':url,
	  		'data':data,
	  		'dataType':'json',
	  		'success':function(data,status){
	  			for(var i=0;i<data.rows.length;i++){
	  				areaHtml+="<option value='"+data.rows[i].dicValue+"' ";
	  				areaHtml+="  >"+data.rows[i].dicValue+"</option>";
	  			}
	  			$form.find('select[name=area]').html(areaHtml).parent().show();
	  	        form.render();
	  	        form.on('select(area)', function(data) {
	  	            var value = data.value;
	  	        });
	  		}
	  	});
    }
	
	var mjs  =	mytooljs.initTable({  
		idSelecter:"#table1",
		sendurl:"${path}/user/finance/FinanceOrg/showList" , //求数据的地址
		pagesize:5,//分页大小
		delUrl:"${path}/user/finance/FinanceOrg/del",//删除数据地址
		editUrl:"${path}/user/finance/FinanceOrg/checkForm", //打开编辑或新增页面地址
		windowSize:{'X':'100%','Y':'100%'}
		});
	
	//操作
	function getStatus(orgStatus){
		var	html="";
		if(orgStatus==-1){
			html+="<span style='color:#A0A0A0;'>未审核<span/>";
		}else if(orgStatus==1){
			html+="<span style='color:green;'>审核通过<span/>";
		}else if(orgStatus==2){
			html+="<span style='color:red;'>审核未通过<span/>";
		}
		return html;
	}
	//状态
	function operation(id){
		var	html="";
		html+="<input type='button' value='查看' class='layui-btn layui-btn-primary layui-btn-small' onclick='mjs.editFrom("+id+")' />";
		return html;
	}
	</script>
	</body>
</html>
